Skip to content

fix: funbox deselection not clearing effects without refresh (@prajith5)#7469

Open
prajith5 wants to merge 1 commit intomonkeytypegame:masterfrom
prajith5:fix-funbox-deselection
Open

fix: funbox deselection not clearing effects without refresh (@prajith5)#7469
prajith5 wants to merge 1 commit intomonkeytypegame:masterfrom
prajith5:fix-funbox-deselection

Conversation

@prajith5
Copy link

@prajith5 prajith5 commented Feb 2, 2026

Fixes an issue where Funbox effects remained active internally after being
deselected until a page refresh.

This change compares the previous and next activation state of a Funbox
and ensures:

  • clearGlobal() is called when a Funbox is deselected
  • applyGlobalCSS() is called only when a Funbox is activated

This guarantees Funbox effects reset immediately without requiring a refresh.

Fixes #7468

@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Feb 2, 2026
@prajith5 prajith5 changed the title Fix Funbox deselection not clearing effects without refresh fix: funbox deselection not clearing effects without refresh Feb 2, 2026
@prajith5 prajith5 changed the title fix: funbox deselection not clearing effects without refresh fix: funbox deselection not clearing effects without refresh (@prajith5) Feb 2, 2026
@Miodec Miodec requested a review from Copilot February 27, 2026 14:20
@github-actions github-actions bot added the waiting for review Pull requests that require a review before continuing label Feb 27, 2026
@Miodec
Copy link
Member

Miodec commented Feb 27, 2026

This PR doesn't seem to fix the issue

@Miodec Miodec added the waiting for update Pull requests or issues that require changes/comments before continuing label Feb 27, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical bug where funbox effects remained active internally after deselection until page refresh (issue #7468).

Changes:

  • Fixed setFunbox() to call clearGlobal() on removed funboxes when switching between funbox sets
  • Fixed toggleFunbox() to properly track activation state transitions and call clearGlobal() when deactivating and applyGlobalCSS() when activating
  • Refactored forced config logic in activate() for better readability with explicit type checking

}

FunboxMemory.load();
setConfig("funbox", funbox);
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setFunbox() function clears removed funboxes but doesn't apply global CSS for newly activated funboxes. When switching from one set of funboxes to another (e.g., from ["nausea"] to ["upside_down"]), the new funbox's applyGlobalCSS() is never called, which could leave it in an incomplete state.

Consider adding logic to detect newly activated funboxes and call their applyGlobalCSS() function, similar to how toggleFunbox() handles this on line 76.

Suggested change
setConfig("funbox", funbox);
setConfig("funbox", funbox);
const currentFunboxes = getActiveFunboxNames();
const addedFunboxes = currentFunboxes.filter(
(fb) => !previousFunboxes.includes(fb),
);
for (const fb of addedFunboxes) {
get(fb).functions?.applyGlobalCSS?.();
}

Copilot uses AI. Check for mistakes.
Comment on lines 35 to 78
@@ -56,12 +59,20 @@ export function toggleFunbox(funbox: FunboxName): void {
);
return;
}

FunboxMemory.load();

const wasActive = getActiveFunboxNames().includes(funbox);

configToggleFunbox(funbox, false);

if (!getActiveFunboxNames().includes(funbox)) {
const isActive = getActiveFunboxNames().includes(funbox);

if (wasActive && !isActive) {
get(funbox).functions?.clearGlobal?.();
} else {
}

if (!wasActive && isActive) {
get(funbox).functions?.applyGlobalCSS?.();
}
}
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to toggleFunbox() and setFunbox() fix a critical bug but lack test coverage. Consider adding tests that verify:

  1. clearGlobal() is called when a funbox is deselected
  2. applyGlobalCSS() is called when a funbox is selected
  3. Multiple funbox effects are properly cleared when switching between different sets

This would prevent regression of the issue described in #7468.

Copilot uses AI. Check for mistakes.
@Miodec Miodec removed the waiting for review Pull requests that require a review before continuing label Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend User interface or web stuff waiting for update Pull requests or issues that require changes/comments before continuing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Funbox deselection does not reset effects without refresh

4 participants